package cn.lystudio.rohmtimeopwide_background_v11.controller.appApi;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.util.SaResult;
import cn.hutool.core.util.ObjectUtil;
import cn.lystudio.rohmtimeopwide_background_v11.entity.po.PlanOutputPO;
import cn.lystudio.rohmtimeopwide_background_v11.service.PlanOutputService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app-api/planOutput")
@CrossOrigin
@SaIgnore
@Slf4j
public class AppPlanOutputController {
    private PlanOutputService planOutputService;

    @Autowired
    public void setPlanOutputService(PlanOutputService planOutputService) {
        this.planOutputService = planOutputService;
    }

    @GetMapping("/getPlanOutput")
    public SaResult getPlanOutput(@RequestParam("machineNo")String machineNo,
                                  @RequestParam("dayOrNight")Integer dayOrNight){
        PlanOutputPO planOutput = planOutputService.getPlanOutput(machineNo, dayOrNight);
        if(ObjectUtil.isEmpty(planOutput)) return SaResult.error("设定异常");
        return SaResult.data(planOutput);
    }


}
